1. Field of the Invention
The present invention relates to a method for determining the correctness of a program code stored in a memory module, and more particularly, to a method for determining the correctness of a program code stored in a memory module in an electronic device.
2. Description of the Prior Art
Microprocessors and memories play an important role in modern information-oriented society, and they are widely used in different electronic apparatuses. For example, in a DVD player, CD-ROM, CD-RW, DVD-ROM, there is a microprocessor that executes a program code stored in a non-volatile memory, such as a flash memory or a ROM, to process data stored in a volatile memory, such as a DRAM or an SRAM, in cooperation with an application specific integrated circuit (ASIC).
The microprocessor operates by executing the program code, which is stored in the non-volatile memory and is also called firmware. For reasons of enhancement, improvement and debugging, most firmware needs to be updated, which is known as a “firmware update” process.
A problem with firmware updates is that they may fail due to electric power failure or incorrect operation. Such kind of firmware update failure causes an extreme system failure to the point that further firmware updates cannot be executed anymore to restore the system. In order to prevent this condition in advance, boot code protection is applied in the prior art. Boot code is a part of the firmware program code that is a section of the program code initially executed whenever the system is powered on or rebooted. The boot code is stored in a boot code section of a non-volatile memory, and the remaining firmware program code is stored in a normal firmware section of the non-volatile memory. In general, the firmware update process updates the program segment stored in the normal firmware section and the boot code stored in the boot code section is not changed during firmware update.
If firmware update fails, the system can execute the boot code to reboot the system after it finishes a specific firmware determining procedure. In such a manner, even if the firmware update fails, the system can reboot again by executing the boot code and then re-perform the firmware update process.
However, one scheme of the firmware determining procedures of the prior art needs to determine the configurations of circuit pins while another scheme needs to pre-store a replica firmware program code in the non-volatile memory. In the later case, the firmware determining procedures of the prior art determine the correctness of the firmware program code by checking whether or not the checksum of the firmware program code equals to the checksum of the replica firmware program code.
As mentioned above, the firmware determining procedure of the prior art requires extra memory space to store the replica firmware program code, so that the cost of circuit is increased. In addition, since the firmware determining procedure of the prior art needs to calculate and compare the checksum of the firmware program code and the checksum of the replica firmware program code, the system performance may be affected. Furthermore, the reliability of the checksum comparison is not sufficiently accurate.